package com.xlh.view.manager;

import android.view.View;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;

import com.xlh.Utils.FUti;
import com.xlh.bean.TitleBean;
import com.xlh.interf.IActivity;
import com.xlh.interf.IAdapter;

/**
 * Created by Administrator on 2018/7/5.
 */

public class FloatRightButListViewManager {
    private IActivity atv;

    public ListView getView() {
        return view;
    }

    public void setView(ListView view) {
        this.view = view;
    }

    private ListView view;
    private IAdapter DataAdapter;
    public IAdapter getDataAdapter() {
        return dataAdapter;
    }

    public FloatRightButListViewManager(IActivity atv, ListView view, IAdapter dataAdapter){
        this.atv = atv;
        this.view = view;

        this.view.setDividerHeight(FUti.dip2px(this.atv.getActivity(),5));

        this.bindEvts();
        this.setDataAdapter(dataAdapter);

    }
    public void setDataAdapter(IAdapter dataAdapter) {
        this.dataAdapter = dataAdapter;
        view.setAdapter((BaseAdapter)this.dataAdapter);
    }

    public void bindEvts(){
        final FloatRightButListViewManager me = this;
        this.view.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                TitleBean data = (TitleBean)((ListView)parent).getAdapter().getItem(position);

                me.atv.getActivity().mSocketClient.sendMsg(data.getmAction());


            }
        });
    }
    private IAdapter dataAdapter;
}
